<html>
<head><meta charset="utf-8"><title>lazy norm future compat · project-const-generics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/index.html">project-const-generics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html">lazy norm future compat</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212735515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20future%20compat/near/212735515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html#212735515">(Oct 08 2020 at 19:05)</a>:</h4>
<p><code>min_const_generics</code> does not use <code>lazy_normalization_consts</code> and enabling <code>lazy_normalization_consts</code> is a breaking change in some rare circumstances. Does the situation get worse by stabilizing <code>min_const_generics</code>?</p>



<a name="212735632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20future%20compat/near/212735632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html#212735632">(Oct 08 2020 at 19:06)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">trait</span><span class="w"> </span><span class="n">Trait</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">ASSOC_CONST</span>: <span class="kt">usize</span> <span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">Trait</span><span class="o">&lt;</span><span class="p">()</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="kt">u8</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="c1">// `u8::ASSOC_CONST` is resolved today, but will be ambiguous</span>
<span class="c1">// under lazy normalization.</span>
<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">U</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="p">[(</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">U</span><span class="p">);</span><span class="w"> </span><span class="kt">u8</span>::<span class="n">ASSOC_CONST</span><span class="p">]</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="kt">u8</span>: <span class="nc">Trait</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">Trait</span><span class="o">&lt;</span><span class="n">U</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">todo</span><span class="o">!</span><span class="p">()</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>



<a name="212735937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20future%20compat/near/212735937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html#212735937">(Oct 08 2020 at 19:09)</a>:</h4>
<p><code>min_const_generics</code> only allows 1 new expression in array lengths, being an identity expression using a const parameter, so it won't have a direct impact on this</p>



<a name="212736130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20future%20compat/near/212736130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html#212736130">(Oct 08 2020 at 19:11)</a>:</h4>
<p>it will however make working with arrays more ergonomic which will probably increase their use. This will probably also mean that there will be a higher chance to encounter an expression which breaks once we stabilize <code>lazy_normalization_consts</code></p>



<a name="212736339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20future%20compat/near/212736339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html#212736339">(Oct 08 2020 at 19:13)</a>:</h4>
<p>I do not think that this is relevant enough to be a concern when deciding to stabilize <code>min_const_generics</code>. In general I do not believe there to be an interaction between <code>lazy_normalization_consts</code> and <code>min_const_generics</code> we have to wary of.</p>



<a name="217663295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20future%20compat/near/217663295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html#217663295">(Nov 23 2020 at 18:13)</a>:</h4>
<p>looks like we have to update this topic because of <a href="https://github.com/rust-lang/rust/issues/79356">#79356</a></p>



<a name="217663477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20future%20compat/near/217663477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html#217663477">(Nov 23 2020 at 18:15)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="116009">@nikomatsakis</span> this seems similar to what you and <span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> are currently doing for supertraits, do you have an idea on how we might be able to fix this?</p>



<a name="217663788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20future%20compat/near/217663788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html#217663788">(Nov 23 2020 at 18:18)</a>:</h4>
<p>this makes me less comfortable with stabilizing <code>min_const_generics</code> as this test works as long as we don't supply the parent generics</p>



<a name="217687386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20future%20compat/near/217687386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html#217687386">(Nov 23 2020 at 21:52)</a>:</h4>
<p>we could discard predicates in <code>tcx.param_env</code>of an anon const if they contain said anon const</p>



<a name="217687410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20future%20compat/near/217687410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html#217687410">(Nov 23 2020 at 21:52)</a>:</h4>
<p>that might actually work quite well I think</p>



<a name="217760369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20future%20compat/near/217760369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html#217760369">(Nov 24 2020 at 14:27)</a>:</h4>
<p>oh well, it won't</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(const_generics)]</span><span class="w"></span>
<span class="cp">#![allow(incomplete_features)]</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">T</span><span class="p">);</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">test</span><span class="p">()</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span>: <span class="nc">Foo</span><span class="o">&lt;</span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="mi">3</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">4</span><span class="p">]</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="mi">3</span><span class="w"></span>
<span class="p">}]</span>: <span class="nb">Sized</span><span class="p">,</span><span class="w"></span>
<span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span>: <span class="nc">Foo</span><span class="o">&lt;</span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="mi">3</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">4</span><span class="p">]</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="mi">4</span><span class="w"></span>
<span class="p">}]</span>: <span class="nb">Sized</span>  <span class="p">{}</span><span class="w"></span>
</code></pre></div>
<p>will still break then</p>



<a name="217760471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20future%20compat/near/217760471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html#217760471">(Nov 24 2020 at 14:28)</a>:</h4>
<p>another idea would be to replace all unevaluated consts in the same <code>Generics</code> with something like <code>ConstKind::Opaque</code> so that we can't look into them</p>



<a name="217760930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20future%20compat/near/217760930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html#217760930">(Nov 24 2020 at 14:32)</a>:</h4>
<p>this would prevent things like</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">test</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">T</span>: <span class="nc">Trait</span><span class="o">&lt;</span><span class="p">{</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="p">}</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="o">&lt;</span><span class="n">T</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">Trait</span><span class="o">&lt;</span><span class="p">{</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="p">}</span><span class="o">&gt;</span>::<span class="n">ASSOC</span><span class="p">]</span>: <span class="nb">Sized</span> <span class="p">{}</span><span class="w"></span>
</code></pre></div>



<a name="217761998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20future%20compat/near/217761998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html#217761998">(Nov 24 2020 at 14:40)</a>:</h4>
<p>thinking about this i feel a bit better as there are ways to solve this and while min_const_generics will slightly increase the amount of unevaluated constants in where clauses, it doesn't change anything substantial here as arrays are already allowed</p>



<a name="217762101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/lazy%20norm%20future%20compat/near/217762101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/lazy.20norm.20future.20compat.html#217762101">(Nov 24 2020 at 14:40)</a>:</h4>
<p>will remove <code>const-generics-blocking</code> from that issue again. cc <span class="user-mention" data-user-id="121053">@varkor</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>